{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "91793aea",
   "metadata": {},
   "outputs": [],
   "source": [
    "change_labels2 = {}\n",
    "for a,b in change_labels1.items():\n",
    "        change_labels2[b]=a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b838aa91",
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_pre_recall():\n",
    "    recall = [0 for i in range(14)]\n",
    "    for i in range(14):\n",
    "        sum=0\n",
    "        for j in range(14):\n",
    "            sum+=pre_sum[j][i]\n",
    "        if sum!=0:\n",
    "            recall[i] = float(pre_sum[i][i])/(float(sum)-2)\n",
    "        else:\n",
    "            recall[i]=-1\n",
    "    return recall\n",
    "recall = get_pre_recall()\n",
    "for i in range(14):\n",
    "    print(change_labels2[i],':',recall[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac9c1776",
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_pre_precission():\n",
    "    prec = [0 for i in range(14)]\n",
    "    for i in range(14):\n",
    "        sum=0\n",
    "        for j in range(14):\n",
    "            sum+=pre_sum[i][j]\n",
    "        if sum!=0:\n",
    "            prec[i] = float(pre_sum[i][i])/(float(sum)-2)\n",
    "        else:\n",
    "            prec[i]=-1\n",
    "    return prec\n",
    "prec = get_pre_precission()\n",
    "for i in range(14):\n",
    "    print(change_labels2[i],':',prec[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99d575e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_pre_f1():\n",
    "    f1 = [0 for i in range(14)]\n",
    "    for i in range(14):\n",
    "        a = prec[i]+recall[i]\n",
    "        if a==0:\n",
    "            a=-1\n",
    "        f1[i]=2*prec[i]*recall[i]/a\n",
    "    return f1\n",
    "f1 = get_pre_f1()\n",
    "kkk = 0\n",
    "for i in range(14):\n",
    "    kkk+=f1[i]\n",
    "    print(change_labels2[i],':',f1[i])\n",
    "print(kkk/14.0)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "bert1",
   "language": "python",
   "name": "bert1"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
